{extend name="base/main" /}
{block name="body"}
<link rel="stylesheet" href="/static/layui/css/layui.css"  media="all">
<script src="/static/layui/layui.js" charset="utf-8"></script>
<div class="ibox-content">
    <form id="f" action="{:url('Marketing/poster_edit')}" class="form-horizontal m-t" method="post" enctype = "multipart/form-data">
        <div class="layui-form">
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">签到时间</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" id="test1" name="time" value="{$res.time}" placeholder="yyyy-MM-dd">
                    </div>
                </div>
            </div>
        </div>
        <div class="layui-upload">
            <label class="col-sm-1 control-label">签到海报：</label>
            <div class="col-sm-4">
                <button type="button" class="layui-btn" id="test2">上传封面</button>
                <div class="layui-upload-list">
                    <img class="layui-upload-img" id="demo1" name="img" value="{$res.img}"  width="95px" height="80px">
                    <p id="demoText"></p>
                    <input type="hidden" name="img" id="img">
                </div>
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">排序</label>
            <div class="layui-input-inline">
                <input type="number" name="sort" value="{$res.sort}" lay-verify="required|phone" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="hr-line-dashed"></div>
        <div class="form-group">
            <div class="col-sm-4 col-sm-offset-3">
                <input type="hidden" name="id" value="{$res.id}">
                <button class="btn btn-primary" type="submit">提交</button>
                <button class="btn btn-default historygo" type="button">返回</button>
            </div>
        </div>
    </form>
</div>

<script>
    layui.use('laydate', function(){
        var laydate = layui.laydate;
        //常规用法
        laydate.render({
            elem: '#test1'
        });
    });
</script>

<!-- 注意：如果你直接复制所有代码到本地，上述 JS 路径需要改成你本地的 -->
<script>
    var ue1 = UE.getEditor('editor_j',{});
    var ue2 = UE.getEditor('editor_n',{});
    layui.use(['upload', 'element', 'layer','form'], function(){
        var $ = layui.jquery
            ,upload = layui.upload
            ,element = layui.element
            ,layer = layui.layer;
        //常规使用 - 普通图片上传
        var uploadInst = upload.render({
            elem: '#test2'
            ,url: "{:url('Marketing/phone')}" //改成自己的上传接口
            ,before: function(obj){
                //预读本地文件示例
                obj.preview(function(index, file, result){
                    $('#demo1').attr('src', result); //图片链接（base64）
                });
            }
            ,done: function(res){
                //如果上传失败
                if(res.code > 0){
                    return layer.msg('上传失败');
                }
                if(res.code == 0){
                    $('#img').val(res.data);
                    return layer.msg('上传成功');
                }
                //上传成功的一些操作
                //……
                $('#demoText').html(''); //置空上传失败的状态
            }

        });
    });
</script>

{/block}